package com.jboom.mongocrud.repository.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.jboom.mongocrud.annotation.AutoId;
import lombok.Data;
import lombok.ToString;
import org.springframework.data.mongodb.core.geo.GeoJsonPoint;
import org.springframework.data.mongodb.core.index.CompoundIndex;
import org.springframework.data.mongodb.core.index.GeoSpatialIndexType;
import org.springframework.data.mongodb.core.index.GeoSpatialIndexed;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.MongoId;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 物流订单
 */
@Data
@Document("logistics_order")
@ToString
public class LogisticsOrder {

    /**
     * 物流订单id
     */
    @MongoId
    @AutoId
    private Long orderId;

    /**
     * 用户id
     */
    private Long userId;

    /**
     * 订单价格
     */
    private BigDecimal price;

    /**
     * 订单总重
     */
    private BigDecimal weight;

    /**
     * 目的地
     */
    private GeoJsonPoint to;

    /**
     * 出发地
     */
    private GeoJsonPoint from;

    /**
     * 当前位置
     */
    @GeoSpatialIndexed(type = GeoSpatialIndexType.GEO_2DSPHERE,useGeneratedName = true)
    private GeoJsonPoint location;

    /**
     * 距离
     */
    private transient Double distance;

    /**
     * 住址信息
     */
    private Address address;

    /**
     * 运送物品
     */
    private List<OrderItem> items;

    /**
     * 0 已发货
     * 1 待收件
     * 2 已揽收
     * 3 运输中
     * 4 配送中
     * 5 已签收
     */
    private Integer status;

    /**
     * 发出时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private LocalDateTime sendTime;

    /**
     * 发出时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private LocalDateTime receiveTime;

    /**
     * 操作者
     */
    private String operator;

    /**
     * 操作时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private LocalDateTime operateTime;

    /**
     * 备注
     */
    private String remark;
}
